home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / misc / gs261src.zip / filedev.h < prev    next >
C/C++ Source or Header  |  1993-05-13  |  4KB  |  112 lines

  1. /* Copyright (C) 1993 Aladdin Enterprises.  All rights reserved.
  2.  
  3. This file is part of Ghostscript.
  4.  
  5. Ghostscript is distributed in the hope that it will be useful, but
  6. WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  7. to anyone for the consequences of using it or for whether it serves any
  8. particular purpose or works at all, unless he says so in writing.  Refer
  9. to the Ghostscript General Public License for full details.
  10.  
  11. Everyone is granted permission to copy, modify and redistribute
  12. Ghostscript, but only under the conditions described in the Ghostscript
  13. General Public License.  A copy of this license is supposed to have been
  14. given to you along with Ghostscript so you can know your rights and
  15. responsibilities.  It should be in a file named COPYING.  Among other
  16. things, the copyright notice and this notice must be preserved on all
  17. copies.  */
  18.  
  19. /* filedev.h */
  20. /* Definition of a file `device' object */
  21.  
  22. /*
  23.  * Note that file devices have nothing to do with Ghostscript output
  24.  * devices.  See section 3.8.2 of the PostScript Language Reference Manual,
  25.  * Second Edition, for more information.
  26.  */
  27.  
  28. struct file_device_s;        /* defined here */
  29. typedef struct file_device_s file_device;
  30.  
  31. struct file_device_procs_s;    /* defined here */
  32. typedef struct file_device_procs_s file_device_procs;
  33.  
  34. #ifndef file_enum_DEFINED        /* also defined in gp.h */
  35. #  define file_enum_DEFINED
  36. struct file_enum_s;    /* opaque to client, defined by implementors */
  37. typedef struct file_enum_s file_enum;
  38. #endif
  39.  
  40. /* Definition of file device procedures */
  41. /* Note that file names for delete, rename, and fopen are C strings, */
  42. /* not pointer + length. */
  43.  
  44. struct file_device_procs_s {
  45.  
  46. #define fdev_proc_init(proc)\
  47.   int proc(P1(file_device *fdev))
  48.     fdev_proc_init((*init));    /* one-time initialization */
  49.  
  50. #define fdev_proc_open_device(proc)\
  51.   int proc(P3(file_device *fdev, const char *access, stream **ps))
  52.     fdev_proc_open_device((*open_device));
  53.  
  54. #define fdev_proc_open_file(proc)\
  55.   int proc(P5(file_device *fdev, const char *fname, uint namelen,\
  56.           const char *access, stream **ps))
  57.     fdev_proc_open_file((*open_file));
  58.  
  59. #define fdev_proc_fopen(proc)\
  60.   FILE *proc(P3(file_device *fdev, const char *fname, const char *access))
  61.     fdev_proc_fopen((*fopen));
  62.  
  63. #define fdev_proc_fclose(proc)\
  64.   int proc(P2(file_device *fdev, FILE *file))
  65.     fdev_proc_fclose((*fclose));
  66.  
  67. #define fdev_proc_delete_file(proc)\
  68.   int proc(P2(file_device *fdev, const char *fname))
  69.     fdev_proc_delete_file((*delete_file));
  70.  
  71. #define fdev_proc_rename_file(proc)\
  72.   int proc(P3(file_device *fdev, const char *from, const char *to))
  73.     fdev_proc_rename_file((*rename_file));
  74.  
  75. #define fdev_proc_enumerate_files(proc)\
  76.   file_enum *proc(P4(file_device *fdev, const char *pat, uint patlen,\
  77.              const gs_memory_procs *mprocs))
  78.     fdev_proc_enumerate_files((*enumerate_files));
  79.  
  80. #define fdev_proc_enumerate_next(proc)\
  81.   uint proc(P3(file_enum *pfen, char *ptr, uint maxlen))
  82.     fdev_proc_enumerate_next((*enumerate_next));
  83.  
  84. #define fdev_proc_enumerate_close(proc)\
  85.   void proc(P1(file_enum *pfen))
  86.     fdev_proc_enumerate_close((*enumerate_close));
  87.  
  88. };
  89.  
  90. /* The following typedef is needed because ansi2knr can't handle */
  91. /* fdev_proc_fopen((*procname)) in a formal argument list. */
  92. typedef fdev_proc_fopen((*fdev_proc_fopen_t));
  93.  
  94. /* Default implementations of procedures */
  95. fdev_proc_init(fdev_no_init);
  96. fdev_proc_open_device(fdev_no_open_device);
  97. fdev_proc_open_file(fdev_no_open_file);
  98. fdev_proc_fopen(fdev_no_fopen);
  99. fdev_proc_fclose(fdev_no_fclose);
  100. fdev_proc_delete_file(fdev_no_delete_file);
  101. fdev_proc_rename_file(fdev_no_rename_file);
  102. fdev_proc_enumerate_files(fdev_no_enumerate_files);
  103. /* The %os% implemention of open_file */
  104. fdev_proc_open_file(fdev_os_open_file);
  105.  
  106. /* Finally, the device structure itself. */
  107.  
  108. struct file_device_s {
  109.     const char *dname;        /* the file device name */
  110.     const file_device_procs procs;
  111. };
  112.